package org.flower.service.impl;

import org.apache.ibatis.session.SqlSession;
import org.flower.bean.Carousel;
import org.flower.bean.CarouselExample;
import org.flower.mapper.CarouselMapper;
import org.flower.service.CarouselService;
import org.flower.utils.MyBatisUtil;

import java.io.IOException;
import java.util.List;

/**
 * 旋转木马服务impl
 *
 * @author Aizen
 * @date 2021/12/27
 */
public class CarouselServiceImpl implements CarouselService {
    @Override
    public List<Carousel> findAllCarousel() {
        try {
            SqlSession sqlSessionFactory = MyBatisUtil.getSqlSessionFactory();
            CarouselMapper mapper = sqlSessionFactory.getMapper(CarouselMapper.class);
            CarouselExample carouselExample = new CarouselExample();
            carouselExample.setOrderByClause("SerialNum");
            List<Carousel> carouselList = mapper.selectByExample(carouselExample);
            sqlSessionFactory.close();
            return carouselList;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
